Skip to content

Tutorials edits - Terminate on configuration error - Terminal Color#2368

Merged
rrayst merged 22 commits into
masterfrom
tutorial-fail-on-error
Dec 8, 2025
Merged

Tutorials edits - Terminate on configuration error - Terminal Color#2368
rrayst merged 22 commits into
masterfrom
tutorial-fail-on-error

Conversation

@predic8

@predic8 predic8 commented Dec 4, 2025

Copy link
Copy Markdown
Member

Summary by CodeRabbit

  • New Features

    • Register JSON Schema for YAML configs (membrane.schema.json).
    • Colorized startup and log output with automatic detection and opt-out; startup scripts propagate setting to the JVM.
    • Improved XML formatting and snippet validation utilities.
  • Bug Fixes

    • Activation now halts and reports errors on initialization failures.
    • Connection termination signaling refined for more predictable shutdown.
    • Removed legacy asynchronous initialization wait APIs.
  • Documentation

    • Updated getting-started tutorials, startup instructions, troubleshooting examples and roadmap.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai

coderabbitai Bot commented Dec 4, 2025

Copy link
Copy Markdown
Contributor

Walkthrough

Introduces terminal color support and detection, centralizes a JSON schema filename constant, changes bean activation to propagate failures, reorganizes text/XML utilities (new XMLTextUtil and util.text package), removes TerminateException from HTTP server handler signatures, updates startup scripts and logging configs, and applies numerous import/package adjustments.

Changes

Cohort / File(s) Summary
Schema constant
\annot/src/main/java/com/predic8/membrane/annot/generator/JsonSchemaGenerator.java``
Added public static final String MEMBRANE_SCHEMA_JSON_FILENAME = "membrane.schema.json" and replaced hard-coded filename usages with the constant.
Bean activation behavior
\annot/src/main/java/com/predic8/membrane/annot/yaml/BeanRegistryImplementation.java``
activationRun now rethrows a RuntimeException after logging on BeanDefinition handling errors (previously only logged).
Terminal colors & logging
\core/src/main/java/com/predic8/membrane/core/util/text/TerminalColors.java`, `core/src/main/java/com/predic8/membrane/core/Constants.java`, `core/src/main/java/com/predic8/membrane/core/interceptor/log/LogInterceptor.java`, `core/src/main/java/com/predic8/membrane/core/proxies/ApiInfo.java`, `core/src/main/java/com/predic8/membrane/core/Router.java`, `core/src/main/java/com/predic8/membrane/core/transport/http/HttpEndpointListener.java`, `core/src/test/resources/log4j2.xml`, `distribution/conf/log4j2.xml`, `distribution/router/conf/log4j2.xml``
Added TerminalColors utility with enable/disable detection, introduced MEMBRANE_DISABLE_TERM_COLORS_PROPERTY, applied ANSI color wrappers to startup/proxy logs, and updated logging configs to support ANSI coloring with a disable toggle.
Startup scripts
\distribution/scripts/start_router.sh`, `distribution/scripts/start_router.cmd``
Added color-detection logic that sets `-Dmembrane.disable.term.colors=<true
HTTP termination signaling
\core/src/main/java/com/predic8/membrane/core/transport/http/HttpServerHandler.java``
Removed TerminateException from multiple method signatures; termination now signaled via return values instead of exceptions.
XML utilities
\core/src/main/java/com/predic8/membrane/core/util/xml/XMLTextUtil.java`, `core/src/test/java/.../SOAPMessageValidatorInterceptorTest.java`, `core/src/main/java/com/predic8/membrane/core/interceptor/administration/AdminRESTInterceptor.java`, `core/src/main/java/com/predic8/membrane/core/interceptor/administration/AdminPageBuilder.java``
Added XMLTextUtil (formatXML, isValidXMLSnippet), switched call sites/tests to XMLTextUtil, and adjusted admin UI helper signatures.
Text util reorg & StringUtil helpers
\core/src/main/java/com/predic8/membrane/core/util/text/TextUtil.java`, `core/src/main/java/com/predic8/membrane/core/util/text/StringUtil.java``, multiple core files*
Moved TextUtil into util.text; moved/renamed StringUtil and added yes(String) / no(String) helpers; updated many imports/static imports across the codebase.
Imports & package adjustments (bulk)
\core/src/main/java/...`, `core/src/test/java/...`(e.g.,GraphQLProtectionInterceptor.java, Message.java, Resource.java, GlobMatcher.java, GroovyInterceptor.java, JavascriptInterceptor.java, Jwks.java, AccessLogInterceptorService.java, RewriteInterceptor.java, ValidatorInterceptor.java, WebServerInterceptor.java, XSLTInterceptor.java, XSLTTransformer.java, RhinoJavascriptLanguageSupport.java, APIProxy.java, TextPrettifier.java, XMLPrettifier.java, Connection.java, core/src/test/java/.../Http11Test.java, core/src/test/java/.../TextUtilTest.java`)
Replaced many imports/static imports from com.predic8.membrane.core.util.TextUtilcom.predic8.membrane.core.util.text.TextUtil, updated references to XMLTextUtil, and removed unused imports.
Docs & tutorials
\distribution/tutorials/getting-started/00-First-API.yaml`, `distribution/tutorials/getting-started/10-Logging.yaml`, `distribution/tutorials/getting-started/40-Basic-Path-Routing.yaml`, `docs/ROADMAP.md``
Minor documentation and tutorial label/format edits, HTTPS example updates, and roadmap entry added for JSON Schema registration.
OS helpers
\core/src/main/java/com/predic8/membrane/core/util/OSUtil.java``
Added OS_NAME_PROPERTY constant and refactored OS detection to read the property via the new constant.
Small refactors / qualifiers
\core/src/main/java/com/predic8/membrane/core/interceptor/xml/Json2XmlInterceptor.java`, `core/src/main/java/com/predic8/membrane/core/proxies/ApiInfo.java``
Qualified enum constant usage, adjusted proxy-kind label strings, and minor formatting/logging changes.

*Many files under core/src/main/java/... updated import paths to the new util.text package.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

  • Areas needing extra attention:
    • core/src/main/java/com/predic8/membrane/core/transport/http/HttpServerHandler.java — confirm callers handle return-based termination and HTTP/2/keep-alive flows.
    • core/src/main/java/com/predic8/membrane/core/util/text/TerminalColors.java & core/src/main/java/com/predic8/membrane/core/Constants.java — verify detection heuristics and property wiring align with logging config and scripts.
    • annot/src/main/java/com/predic8/membrane/annot/yaml/BeanRegistryImplementation.java — ensure RuntimeException propagation is intentional and handled upstream.
    • core/src/main/java/com/predic8/membrane/core/util/xml/XMLTextUtil.java — review parsing/formatting resource handling and exception semantics.
    • Bulk import/package moves — scan for missed references, ambiguous static imports, and compilation issues.

Possibly related PRs

Suggested reviewers

  • rrayst
  • christiangoerdes

"🐇 I hopped through code with nimble feet,
Bright colors stitched each startup tweet,
XML and text found tidy homes,
A schema named, fewer exceptions roam,
Hooray — the logs now glow and meet!"

Pre-merge checks and finishing touches

❌ Failed checks (1 warning, 1 inconclusive)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 7.29% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
Title check ❓ Inconclusive The title covers three distinct features: tutorial edits, termination on config errors, and terminal color support. While all are present in the changeset, the title is overly broad and does not clearly highlight the primary change. Consider using a more focused title that emphasizes the primary feature, such as 'Add terminal color support to startup logs' or 'Refactor: Move TextUtil to util.text package and add terminal colors', followed by secondary features if needed.
✅ Passed checks (1 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch tutorial-fail-on-error

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 103248b and 16ef6d2.

📒 Files selected for processing (3)
  • distribution/tutorials/getting-started/00-First-API.yaml (1 hunks)
  • distribution/tutorials/getting-started/10-Logging.yaml (1 hunks)
  • distribution/tutorials/getting-started/40-Basic-Path-Routing.yaml (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • distribution/tutorials/getting-started/00-First-API.yaml
  • distribution/tutorials/getting-started/40-Basic-Path-Routing.yaml
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Analyze (java)
🔇 Additional comments (1)
distribution/tutorials/getting-started/10-Logging.yaml (1)

12-12: LGTM! This improves clarity and portability of the tutorial instructions.

Adding the ./ prefix to explicitly reference the script from the current directory is a shell scripting best practice and makes the command clearer for users following the tutorial.

If this change is part of a broader tutorial update, please verify that similar startup instructions in other tutorial files (e.g., other YAML files in distribution/tutorials/) have been updated consistently for coherence.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 49d3228 and 3a69914.

📒 Files selected for processing (6)
  • annot/src/main/java/com/predic8/membrane/annot/generator/JsonSchemaGenerator.java (2 hunks)
  • annot/src/main/java/com/predic8/membrane/annot/yaml/BeanRegistryImplementation.java (1 hunks)
  • distribution/tutorials/getting-started/00-First-API.yaml (1 hunks)
  • distribution/tutorials/getting-started/10-Logging.yaml (1 hunks)
  • distribution/tutorials/getting-started/40-Basic-Path-Routing.yaml (2 hunks)
  • docs/ROADMAP.md (1 hunks)
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-10-23T13:04:11.388Z
Learnt from: predic8
Repo: membrane/api-gateway PR: 2240
File: annot/src/main/java/com/predic8/membrane/annot/generator/JsonSchemaGenerator.java:210-215
Timestamp: 2025-10-23T13:04:11.388Z
Learning: In JsonSchemaGenerator.java, when allowForeign is true for non-list child elements, use a property named "ref" (not "$ref") with type "string" to provide IDE completion hints for Spring bean references while avoiding JSON Schema keyword collision.

Applied to files:

  • annot/src/main/java/com/predic8/membrane/annot/generator/JsonSchemaGenerator.java
🪛 markdownlint-cli2 (0.18.1)
docs/ROADMAP.md

19-19: Bare URL used

(MD034, no-bare-urls)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: Automated tests
  • GitHub Check: Analyze (java)
🔇 Additional comments (8)
distribution/tutorials/getting-started/10-Logging.yaml (1)

12-12: LGTM!

Adding the ./ prefix improves clarity and follows shell script best practices for executing scripts in the current directory.

distribution/tutorials/getting-started/40-Basic-Path-Routing.yaml (2)

32-33: Helpful informational comment.

This comment appropriately warns users that the external API may occasionally fail, improving the tutorial experience.


41-42: Helpful informational comment.

This comment appropriately warns users about potential response delays, setting proper expectations for the tutorial.

distribution/tutorials/getting-started/00-First-API.yaml (2)

8-29: LGTM!

The formatting improvements (numbering style from 1) to 1. and added spacing) enhance readability and consistency across the tutorial documentation.


33-33: Good practice to use HTTPS.

Updating the troubleshooting example to use HTTPS is appropriate since the target API in the configuration uses HTTPS.

annot/src/main/java/com/predic8/membrane/annot/yaml/BeanRegistryImplementation.java (1)

144-147: Fail-fast behavior on configuration errors implemented correctly.

The addition of throw new RuntimeException(e); ensures that Membrane terminates immediately when a bean definition cannot be activated, preventing startup with invalid or partial configuration. This aligns with the PR objective "Terminate on configuration error" and follows the fail-fast principle for improved reliability.

annot/src/main/java/com/predic8/membrane/annot/generator/JsonSchemaGenerator.java (1)

171-171: LGTM!

Correctly uses the newly defined constant, eliminating the hardcoded string and improving maintainability.

docs/ROADMAP.md (1)

18-22: LGTM!

The roadmap additions are clear and well-formatted. Note: The static analysis warning about the bare URL on line 19 is a false positive—the URL is appropriately used in the roadmap context and doesn't require markdown link syntax.

@predic8 predic8 changed the title Tutorials edits - Terminate on configuration error Tutorials edits - Terminate on configuration error - Terminal Color Dec 4, 2025

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (5)
core/src/main/java/com/predic8/membrane/core/transport/http/HttpEndpointListener.java (1)

95-95: Consider making ANSI color codes configurable or abstracting them.

Hard-coded ANSI escape sequences will appear as raw text in log aggregators (Splunk, CloudWatch, ELK), break structured logging parsers, and clutter file-based logs. Consider:

  • Adding a configuration flag to enable/disable colorized output
  • Using a logging utility or constant to centralize color formatting
  • Detecting terminal support before applying colors (e.g., check if System.console() is available)

</invoke_end -->

core/src/main/java/com/predic8/membrane/core/Router.java (1)

358-358: Consider making ANSI color codes configurable or abstracting them.

Hard-coded ANSI escape sequences in log messages will appear as raw text in log aggregators, break structured logging, and clutter non-terminal outputs. The same formatting is applied in two places (lines 358 and 688), suggesting an opportunity to centralize this logic.

Consider:

  • Adding a configuration option to enable/disable colorized console output
  • Creating a utility method or constant for formatted messages
  • Detecting if output is a TTY before applying colors

Also applies to: 688-688

core/src/main/java/com/predic8/membrane/core/proxies/ApiInfo.java (3)

37-37: Consider making ANSI color codes configurable or abstracting them.

Hard-coded ANSI escape sequences will pollute logs in production environments where output is redirected to log aggregators or files. This affects observability and log parsing.

Consider centralizing color formatting logic with the same approach used in HttpEndpointListener and Router, ideally with a configuration flag to control colorization.


45-45: Removed descriptive text reduces log clarity.

The previous text " using OpenAPI specifications:" helped users understand what the subsequent indented list represented. Without this label, the output is less self-documenting, especially for operators unfamiliar with the system.

Consider retaining some descriptive text or ensuring the format is clearly documented.


71-71: APIProxy returns an empty prefix, creating format inconsistency.

While other proxy types now have labeled prefixes (e.g., "Service:", "SOAP:"), APIProxy returns an empty string. This creates a formatting inconsistency in log output, though it may be an intentional design choice to treat API proxies as the default type.

Consider whether APIProxy should have a prefix for consistency, or document this design decision.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3a69914 and 80c313d.

📒 Files selected for processing (3)
  • core/src/main/java/com/predic8/membrane/core/Router.java (2 hunks)
  • core/src/main/java/com/predic8/membrane/core/proxies/ApiInfo.java (2 hunks)
  • core/src/main/java/com/predic8/membrane/core/transport/http/HttpEndpointListener.java (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: Automated tests
  • GitHub Check: Analyze (java)
🔇 Additional comments (1)
core/src/main/java/com/predic8/membrane/core/proxies/ApiInfo.java (1)

74-74: LGTM: Consistent addition of colons improves log formatting.

Adding colons to the proxy type labels (e.g., "Service:", "SOAP:", "Internal:", "Proxy:") provides consistent formatting and improves readability of the log output.

Also applies to: 77-77, 80-80, 82-82

Comment thread core/src/main/java/com/predic8/membrane/core/proxies/ApiInfo.java Outdated
@rrayst rrayst added the 7.x label Dec 5, 2025

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 80c313d and c7fec61.

📒 Files selected for processing (4)
  • distribution/tutorials/getting-started/00-First-API.yaml (1 hunks)
  • distribution/tutorials/getting-started/10-Logging.yaml (1 hunks)
  • distribution/tutorials/getting-started/40-Basic-Path-Routing.yaml (2 hunks)
  • docs/ROADMAP.md (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • distribution/tutorials/getting-started/40-Basic-Path-Routing.yaml
🧰 Additional context used
🪛 markdownlint-cli2 (0.18.1)
docs/ROADMAP.md

26-26: Bare URL used

(MD034, no-bare-urls)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Analyze (java)
🔇 Additional comments (5)
distribution/tutorials/getting-started/10-Logging.yaml (1)

13-13: Shell script path improved for explicit local execution.

Adding ./ prefix to the shell invocation is a best practice that ensures the local script is executed rather than relying on PATH resolution. This makes the tutorial more robust across different environments.

distribution/tutorials/getting-started/00-First-API.yaml (3)

9-9: Improved tutorial structure with consistent formatting and next-step guidance.

The numbering format update (1)1.)) provides visual consistency with standard enumeration. Adding step 4 with a reference to 10-Logging.yaml creates a clear tutorial progression path, which is especially helpful for users just starting.

Also applies to: 19-19, 26-26, 29-29


13-13: Consistent shell script path improvement.

This change aligns with the same update in 10-Logging.yaml and ensures local script execution across both tutorials.


34-34: HTTPS upgrade improves security consistency.

The troubleshooting section now correctly uses HTTPS (https://api.predic8.de) in both the curl example and the API configuration. This ensures the tutorial is consistent with real-world API behavior and modern security practices.

Also applies to: 39-39

docs/ROADMAP.md (1)

25-25: Roadmap additions are well-motivated.

The new entries for startup log colorization and the bom distribution question align with the PR objectives and enhance roadmap clarity.

Also applies to: 27-29

Comment thread docs/ROADMAP.md Outdated
@membrane-ci-server

Copy link
Copy Markdown

This pull request needs "/ok-to-test" from an authorized committer.

@rrayst

rrayst commented Dec 5, 2025

Copy link
Copy Markdown
Member

/ok-to-test

…ed new `TerminalColors` and `XMLTextUtil` classes

- Moved text-related utilities to `com.predic8.membrane.core.util.text` package.
- Introduced `TerminalColors` class for ANSI terminal color handling.
- Added `XMLTextUtil` class with utilities for XML formatting and validation.
- Updated class references and imports across the codebase to reflect package restructuring.
- Enhanced logging configuration to support color highlighting.
… warnings

- Removed redundant methods no longer in use (`waitForAsynchronousInitialization`, `isAsynchronousInitialization`).
- Improved type-checking with modern Java features (e.g., `instanceof` with variable binding).
- Refined helper method signatures to reduce unnecessary parameters.
- Suppressed unused warning in `TerminalColors`.
- Updated exception types to match method requirements.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 4

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
core/src/main/java/com/predic8/membrane/core/transport/http/HttpServerHandler.java (1)

177-221: Remove unnecessary TerminateException from method signatures

process() now declares only throws IOException, but processHttp1Request() and processSingleRequest() still include TerminateException in their throws clauses. No code path in either method actually throws TerminateExceptionreadAndParseRequest(), process(), determineConnectionContinuation(), and Http2ServerHandler.handle() all omit it from their signatures. These declarations can be safely removed.

♻️ Duplicate comments (1)
docs/ROADMAP.md (1)

29-29: Format bare URL as markdown link (flagged in prior review).

This bare URL violates markdown best practices (MD034). Wrap it in bracket-parenthesis syntax to create a proper link.

- Register JSON Schema for YAML at: https://www.schemastore.org/
+ Register JSON Schema for YAML at: [schemastore.org](https://www.schemastore.org/)
🧹 Nitpick comments (4)
docs/ROADMAP.md (1)

21-23: Consider reformulating the @coderabbitai directive as a formal TODO or note.

The instruction to "coderabbitai look through the code base for usages" embedded in line 23 appears to be an external directive rather than documentation. For a roadmap, consider rephrasing as a formal TODO or moving to an issue tracker so the intent is clearer to future readers.

Example reformulation:

- Central desciption of MEMBRANE_* environment variables
  - Like MEMBRANE_HOME...
  - @coderabbitai look through the code base for usages of these variables and suggest documentation
+ Central description of MEMBRANE_* environment variables
  - Like MEMBRANE_HOME...
  - TODO: Document all MEMBRANE_* environment variables and their usages throughout the codebase
annot/src/test/java/com/predic8/membrane/annot/util/GrammarMock.java (1)

26-26: Consider declaring field using the Map interface type.

For consistency with the "program to interfaces" principle, consider using Map<String, Class<?>> as the field type. This is a minor style point for test utility code.

-    private HashMap<String, Class<?>> elements = new HashMap<>();
+    private Map<String, Class<?>> elements = new HashMap<>();
core/src/main/java/com/predic8/membrane/core/util/text/TerminalColors.java (1)

120-160: ANSI detection logic is comprehensive and well-structured.

The detectAnsiSupport() method handles multiple environments appropriately:

  • User override via MEMBRANE_COLORS environment variable
  • CI environment detection
  • IDE support (IntelliJ, VSCode)
  • Terminal capability checks via TERM variable
  • Platform-specific logic for Windows

The implementation is thread-safe with the volatile flag and provides a clean API that returns empty strings when disabled.

One optional consideration: Line 159 returns true as a last-resort default, which is optimistic. In rare cases where none of the checks match, this could enable ANSI in unsupported environments. Consider whether returning false would be safer, though the current approach favors modern terminal support.

core/src/main/java/com/predic8/membrane/core/util/text/StringUtil.java (1)

15-16: yes()/no() helpers look correct; consider documenting accepted values

The new yes(String)/no(String) methods are null‑safe and handle a good set of case‑insensitive tokens (on/off, yes/no, true/false, 1/0, enable[d]/disable[d]). To make their contract clearer to callers, you could add brief Javadoc listing these values.

@@
-    public static boolean yes(String override) {
+    /**
+     * Returns {@code true} for common affirmative values (case-insensitive,
+     * surrounding whitespace ignored): {@code "on"}, {@code "yes"}, {@code "y"},
+     * {@code "true"}, {@code "1"}, {@code "enable"}, {@code "enabled"}.
+     */
+    public static boolean yes(String override) {
@@
-    public static boolean no(String override) {
+    /**
+     * Returns {@code true} for common negative values (case-insensitive,
+     * surrounding whitespace ignored): {@code "off"}, {@code "no"}, {@code "n"},
+     * {@code "false"}, {@code "0"}, {@code "disable"}, {@code "disabled"}.
+     */
+    public static boolean no(String override) {

Also applies to: 65-83

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c7fec61 and 9c69104.

📒 Files selected for processing (50)
  • annot/src/test/java/com/predic8/membrane/annot/util/GrammarMock.java (1 hunks)
  • annot/src/test/java/com/predic8/membrane/annot/yaml/MethodSetterTest.java (1 hunks)
  • core/src/main/java/com/predic8/membrane/core/Router.java (3 hunks)
  • core/src/main/java/com/predic8/membrane/core/exchangestore/FileExchangeStore.java (1 hunks)
  • core/src/main/java/com/predic8/membrane/core/graphql/GraphQLProtectionInterceptor.java (1 hunks)
  • core/src/main/java/com/predic8/membrane/core/http/Message.java (1 hunks)
  • core/src/main/java/com/predic8/membrane/core/interceptor/acl/Resource.java (1 hunks)
  • core/src/main/java/com/predic8/membrane/core/interceptor/acl/matchers/GlobMatcher.java (1 hunks)
  • core/src/main/java/com/predic8/membrane/core/interceptor/administration/AdminPageBuilder.java (5 hunks)
  • core/src/main/java/com/predic8/membrane/core/interceptor/administration/AdminRESTInterceptor.java (1 hunks)
  • core/src/main/java/com/predic8/membrane/core/interceptor/groovy/GroovyInterceptor.java (1 hunks)
  • core/src/main/java/com/predic8/membrane/core/interceptor/javascript/JavascriptInterceptor.java (1 hunks)
  • core/src/main/java/com/predic8/membrane/core/interceptor/jwt/Jwks.java (1 hunks)
  • core/src/main/java/com/predic8/membrane/core/interceptor/log/access/AccessLogInterceptorService.java (1 hunks)
  • core/src/main/java/com/predic8/membrane/core/interceptor/rewrite/RewriteInterceptor.java (1 hunks)
  • core/src/main/java/com/predic8/membrane/core/interceptor/schemavalidation/ValidatorInterceptor.java (1 hunks)
  • core/src/main/java/com/predic8/membrane/core/interceptor/server/WebServerInterceptor.java (1 hunks)
  • core/src/main/java/com/predic8/membrane/core/interceptor/templating/AbstractTemplateInterceptor.java (1 hunks)
  • core/src/main/java/com/predic8/membrane/core/interceptor/templating/TemplateInterceptor.java (1 hunks)
  • core/src/main/java/com/predic8/membrane/core/interceptor/xml/Json2XmlInterceptor.java (1 hunks)
  • core/src/main/java/com/predic8/membrane/core/interceptor/xslt/XSLTInterceptor.java (1 hunks)
  • core/src/main/java/com/predic8/membrane/core/interceptor/xslt/XSLTTransformer.java (1 hunks)
  • core/src/main/java/com/predic8/membrane/core/lang/javascript/RhinoJavascriptLanguageSupport.java (1 hunks)
  • core/src/main/java/com/predic8/membrane/core/lang/jsonpath/JsonpathExchangeExpression.java (1 hunks)
  • core/src/main/java/com/predic8/membrane/core/lang/spel/spelable/SpELCookie.java (1 hunks)
  • core/src/main/java/com/predic8/membrane/core/lang/spel/spelable/SpELHeader.java (1 hunks)
  • core/src/main/java/com/predic8/membrane/core/openapi/serviceproxy/APIProxy.java (1 hunks)
  • core/src/main/java/com/predic8/membrane/core/prettifier/TextPrettifier.java (1 hunks)
  • core/src/main/java/com/predic8/membrane/core/prettifier/XMLPrettifier.java (1 hunks)
  • core/src/main/java/com/predic8/membrane/core/proxies/ApiInfo.java (3 hunks)
  • core/src/main/java/com/predic8/membrane/core/transport/http/Connection.java (1 hunks)
  • core/src/main/java/com/predic8/membrane/core/transport/http/HttpEndpointListener.java (3 hunks)
  • core/src/main/java/com/predic8/membrane/core/transport/http/HttpServerHandler.java (2 hunks)
  • core/src/main/java/com/predic8/membrane/core/util/OSUtil.java (1 hunks)
  • core/src/main/java/com/predic8/membrane/core/util/json/JsonToXml.java (1 hunks)
  • core/src/main/java/com/predic8/membrane/core/util/text/StringUtil.java (2 hunks)
  • core/src/main/java/com/predic8/membrane/core/util/text/TerminalColors.java (1 hunks)
  • core/src/main/java/com/predic8/membrane/core/util/text/TextUtil.java (2 hunks)
  • core/src/main/java/com/predic8/membrane/core/util/xml/XMLTextUtil.java (1 hunks)
  • core/src/test/java/com/predic8/membrane/core/http/Http11Test.java (1 hunks)
  • core/src/test/java/com/predic8/membrane/core/interceptor/schemavalidation/SOAPMessageValidatorInterceptorTest.java (2 hunks)
  • core/src/test/java/com/predic8/membrane/core/lang/spel/spelable/SPeLablePropertyAwareTest.java (1 hunks)
  • core/src/test/java/com/predic8/membrane/core/util/StringUtilTest.java (1 hunks)
  • core/src/test/java/com/predic8/membrane/core/util/TextUtilTest.java (1 hunks)
  • core/src/test/java/com/predic8/membrane/core/util/json/JsonToXmlTest.java (1 hunks)
  • core/src/test/resources/log4j2.xml (1 hunks)
  • distribution/conf/log4j2.xml (1 hunks)
  • distribution/router/conf/log4j2.xml (1 hunks)
  • distribution/src/main/java/com/predic8/membrane/core/FilterExamples.java (1 hunks)
  • docs/ROADMAP.md (1 hunks)
✅ Files skipped from review due to trivial changes (11)
  • core/src/main/java/com/predic8/membrane/core/interceptor/xslt/XSLTInterceptor.java
  • core/src/test/java/com/predic8/membrane/core/util/TextUtilTest.java
  • core/src/test/java/com/predic8/membrane/core/util/json/JsonToXmlTest.java
  • core/src/main/java/com/predic8/membrane/core/lang/spel/spelable/SpELCookie.java
  • core/src/main/java/com/predic8/membrane/core/interceptor/rewrite/RewriteInterceptor.java
  • core/src/main/java/com/predic8/membrane/core/interceptor/xml/Json2XmlInterceptor.java
  • core/src/main/java/com/predic8/membrane/core/lang/jsonpath/JsonpathExchangeExpression.java
  • core/src/main/java/com/predic8/membrane/core/lang/javascript/RhinoJavascriptLanguageSupport.java
  • distribution/src/main/java/com/predic8/membrane/core/FilterExamples.java
  • core/src/main/java/com/predic8/membrane/core/interceptor/groovy/GroovyInterceptor.java
  • core/src/main/java/com/predic8/membrane/core/prettifier/XMLPrettifier.java
🚧 Files skipped from review as they are similar to previous changes (2)
  • core/src/main/java/com/predic8/membrane/core/Router.java
  • core/src/main/java/com/predic8/membrane/core/proxies/ApiInfo.java
🧰 Additional context used
🧠 Learnings (6)
📚 Learning: 2025-06-18T12:03:09.931Z
Learnt from: rrayst
Repo: membrane/api-gateway PR: 1906
File: core/src/test/java/com/predic8/membrane/core/openapi/validators/JsonSchemaTestSuiteTests.java:0-0
Timestamp: 2025-06-18T12:03:09.931Z
Learning: The mediaType method in the Request class throws jakarta.mail.internet.ParseException, not java.text.ParseException, making the jakarta.mail.internet.ParseException import necessary and correct in JsonSchemaTestSuiteTests.java.

Applied to files:

  • core/src/test/java/com/predic8/membrane/core/http/Http11Test.java
📚 Learning: 2025-11-15T18:38:23.728Z
Learnt from: predic8
Repo: membrane/api-gateway PR: 2322
File: core/src/main/java/com/predic8/membrane/core/lang/CommonBuiltInFunctions.java:18-26
Timestamp: 2025-11-15T18:38:23.728Z
Learning: In the membrane/api-gateway repository, the maintainer predic8 prefers fail-fast behavior where NullPointerExceptions are allowed to crash rather than being caught or having defensive null checks that silently return null, as it makes debugging easier by showing where problems originate.

Applied to files:

  • core/src/main/java/com/predic8/membrane/core/interceptor/server/WebServerInterceptor.java
📚 Learning: 2025-06-18T12:03:09.931Z
Learnt from: rrayst
Repo: membrane/api-gateway PR: 1906
File: core/src/test/java/com/predic8/membrane/core/openapi/validators/JsonSchemaTestSuiteTests.java:0-0
Timestamp: 2025-06-18T12:03:09.931Z
Learning: The mediaType method in the Message class (which Request extends) throws jakarta.mail.internet.ParseException because it creates a ContentType object for parsing MIME media types. The jakarta.mail.internet.ParseException import is correct and necessary in test files that call mediaType().

Applied to files:

  • core/src/main/java/com/predic8/membrane/core/http/Message.java
📚 Learning: 2025-08-22T15:02:24.810Z
Learnt from: predic8
Repo: membrane/api-gateway PR: 2068
File: core/src/main/java/com/predic8/membrane/core/util/TextUtil.java:119-128
Timestamp: 2025-08-22T15:02:24.810Z
Learning: XMLBeautifier.parse(InputStream) throws Exception, not XMLStreamException specifically, so catching IOException in TextUtil.formatXML is appropriate for handling IO errors during XML parsing.

Applied to files:

  • core/src/main/java/com/predic8/membrane/core/util/text/TextUtil.java
  • core/src/main/java/com/predic8/membrane/core/util/xml/XMLTextUtil.java
📚 Learning: 2025-08-22T15:02:24.810Z
Learnt from: predic8
Repo: membrane/api-gateway PR: 2068
File: core/src/main/java/com/predic8/membrane/core/util/TextUtil.java:119-128
Timestamp: 2025-08-22T15:02:24.810Z
Learning: XMLBeautifier.parse(InputStream) throws IOException specifically, not Exception. It internally wraps any XMLStreamException or other parsing exceptions in an IOException. Therefore, catching IOException in TextUtil.formatXML is the correct approach for handling XML parsing errors from InputStream.

Applied to files:

  • core/src/main/java/com/predic8/membrane/core/util/text/TextUtil.java
  • core/src/main/java/com/predic8/membrane/core/util/xml/XMLTextUtil.java
📚 Learning: 2025-08-22T15:02:24.810Z
Learnt from: predic8
Repo: membrane/api-gateway PR: 2068
File: core/src/main/java/com/predic8/membrane/core/util/TextUtil.java:119-128
Timestamp: 2025-08-22T15:02:24.810Z
Learning: XMLBeautifier.parse(InputStream) and XMLBeautifier.parse(Reader) both declare "throws Exception" in their signatures, not XMLStreamException specifically. Catching IOException is appropriate for handling IO errors during XML parsing with XMLBeautifier.

Applied to files:

  • core/src/main/java/com/predic8/membrane/core/util/text/TextUtil.java
  • core/src/main/java/com/predic8/membrane/core/util/xml/XMLTextUtil.java
🧬 Code graph analysis (23)
core/src/test/java/com/predic8/membrane/core/http/Http11Test.java (1)
core/src/main/java/com/predic8/membrane/core/util/text/TextUtil.java (1)
  • TextUtil (33-270)
core/src/main/java/com/predic8/membrane/core/exchangestore/FileExchangeStore.java (1)
core/src/main/java/com/predic8/membrane/core/util/xml/XMLTextUtil.java (1)
  • XMLTextUtil (27-96)
core/src/main/java/com/predic8/membrane/core/interceptor/administration/AdminRESTInterceptor.java (1)
core/src/main/java/com/predic8/membrane/core/util/xml/XMLTextUtil.java (1)
  • XMLTextUtil (27-96)
core/src/main/java/com/predic8/membrane/core/openapi/serviceproxy/APIProxy.java (1)
core/src/main/java/com/predic8/membrane/core/util/text/StringUtil.java (1)
  • StringUtil (19-86)
core/src/test/java/com/predic8/membrane/core/interceptor/schemavalidation/SOAPMessageValidatorInterceptorTest.java (1)
core/src/main/java/com/predic8/membrane/core/util/xml/XMLTextUtil.java (1)
  • XMLTextUtil (27-96)
core/src/test/java/com/predic8/membrane/core/util/StringUtilTest.java (1)
core/src/main/java/com/predic8/membrane/core/util/text/StringUtil.java (1)
  • StringUtil (19-86)
core/src/main/java/com/predic8/membrane/core/interceptor/javascript/JavascriptInterceptor.java (1)
core/src/main/java/com/predic8/membrane/core/util/text/TextUtil.java (1)
  • TextUtil (33-270)
core/src/main/java/com/predic8/membrane/core/lang/spel/spelable/SpELHeader.java (1)
core/src/main/java/com/predic8/membrane/core/util/text/TextUtil.java (1)
  • TextUtil (33-270)
core/src/main/java/com/predic8/membrane/core/transport/http/Connection.java (1)
core/src/main/java/com/predic8/membrane/core/util/text/TextUtil.java (1)
  • TextUtil (33-270)
core/src/main/java/com/predic8/membrane/core/interceptor/log/access/AccessLogInterceptorService.java (1)
core/src/main/java/com/predic8/membrane/core/util/text/TextUtil.java (1)
  • TextUtil (33-270)
core/src/main/java/com/predic8/membrane/core/interceptor/schemavalidation/ValidatorInterceptor.java (1)
core/src/main/java/com/predic8/membrane/core/util/text/TextUtil.java (1)
  • TextUtil (33-270)
core/src/main/java/com/predic8/membrane/core/interceptor/acl/Resource.java (1)
core/src/main/java/com/predic8/membrane/core/util/text/TextUtil.java (1)
  • TextUtil (33-270)
core/src/test/java/com/predic8/membrane/core/lang/spel/spelable/SPeLablePropertyAwareTest.java (1)
core/src/main/java/com/predic8/membrane/core/util/text/TextUtil.java (1)
  • TextUtil (33-270)
core/src/main/java/com/predic8/membrane/core/interceptor/jwt/Jwks.java (1)
core/src/main/java/com/predic8/membrane/core/util/text/TextUtil.java (1)
  • TextUtil (33-270)
core/src/main/java/com/predic8/membrane/core/interceptor/administration/AdminPageBuilder.java (1)
core/src/main/java/com/predic8/membrane/core/util/xml/XMLTextUtil.java (1)
  • XMLTextUtil (27-96)
core/src/main/java/com/predic8/membrane/core/prettifier/TextPrettifier.java (1)
core/src/main/java/com/predic8/membrane/core/util/text/TextUtil.java (1)
  • TextUtil (33-270)
core/src/main/java/com/predic8/membrane/core/http/Message.java (1)
core/src/main/java/com/predic8/membrane/core/util/text/TextUtil.java (1)
  • TextUtil (33-270)
core/src/main/java/com/predic8/membrane/core/interceptor/templating/TemplateInterceptor.java (1)
core/src/main/java/com/predic8/membrane/core/util/text/StringUtil.java (1)
  • StringUtil (19-86)
core/src/main/java/com/predic8/membrane/core/interceptor/xslt/XSLTTransformer.java (1)
core/src/main/java/com/predic8/membrane/core/util/text/TextUtil.java (1)
  • TextUtil (33-270)
core/src/main/java/com/predic8/membrane/core/interceptor/templating/AbstractTemplateInterceptor.java (1)
core/src/main/java/com/predic8/membrane/core/util/text/StringUtil.java (1)
  • StringUtil (19-86)
core/src/main/java/com/predic8/membrane/core/util/text/TerminalColors.java (2)
core/src/main/java/com/predic8/membrane/core/util/text/StringUtil.java (1)
  • StringUtil (19-86)
core/src/main/java/com/predic8/membrane/core/util/OSUtil.java (1)
  • OSUtil (21-52)
core/src/main/java/com/predic8/membrane/core/interceptor/acl/matchers/GlobMatcher.java (1)
core/src/main/java/com/predic8/membrane/core/util/text/TextUtil.java (1)
  • TextUtil (33-270)
core/src/main/java/com/predic8/membrane/core/util/xml/XMLTextUtil.java (1)
core/src/main/java/com/predic8/xml/beautifier/XMLInputFactoryFactory.java (1)
  • XMLInputFactoryFactory (24-60)
🪛 LanguageTool
docs/ROADMAP.md

[grammar] ~21-~21: Ensure spelling is correct
Context: ...ystem.console() is available) - Central desciption of MEMBRANE_* environment variables -...

(QB_NEW_EN_ORTHOGRAPHY_ERROR_IDS_1)

🪛 markdownlint-cli2 (0.18.1)
docs/ROADMAP.md

29-29: Bare URL used

(MD034, no-bare-urls)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: Automated tests
  • GitHub Check: Analyze (java)
🔇 Additional comments (35)
core/src/main/java/com/predic8/membrane/core/util/json/JsonToXml.java (1)

1-14: LGTM!

The Apache 2.0 license header is correctly formatted and aligns with the PR's objective of adding license headers across the codebase.

core/src/test/java/com/predic8/membrane/core/lang/spel/spelable/SPeLablePropertyAwareTest.java (1)

21-21: LGTM! Clean import path update.

The static import has been correctly updated to reflect the relocation of TextUtil to the util.text package.

core/src/main/java/com/predic8/membrane/core/interceptor/acl/Resource.java (1)

31-31: LGTM! Clean refactoring.

The import path update correctly reflects the new package structure for TextUtil. The usage at line 69 remains valid and unchanged.

annot/src/test/java/com/predic8/membrane/annot/util/GrammarMock.java (2)

28-46: LGTM!

The interface method implementations are appropriate for a test mock. Returning null/empty values for unneeded methods and delegating to the internal map for getElement is clean and functional.


48-51: LGTM!

The fluent builder method provides good ergonomics for test setup, enabling clean method chaining when configuring the mock.

annot/src/test/java/com/predic8/membrane/annot/yaml/MethodSetterTest.java (1)

1-13: Apache 2.0 license header is correct and well‑placed

The header text matches the standard Apache 2.0 license wording and is correctly positioned above the package declaration; no issues from a legal or technical standpoint.

core/src/main/java/com/predic8/membrane/core/interceptor/javascript/JavascriptInterceptor.java (1)

23-23: LGTM!

The import path update aligns with the TextUtil package reorganization into util.text.

core/src/main/java/com/predic8/membrane/core/http/Message.java (1)

28-28: LGTM!

The static import update correctly reflects the TextUtil package relocation.

core/src/main/java/com/predic8/membrane/core/interceptor/xslt/XSLTTransformer.java (1)

26-26: LGTM!

The import path change is consistent with the TextUtil package reorganization.

core/src/main/java/com/predic8/membrane/core/util/text/TerminalColors.java (1)

31-32: Private constructor correctly prevents instantiation.

This is the appropriate pattern for a utility class with only static methods.

core/src/main/java/com/predic8/membrane/core/transport/http/HttpEndpointListener.java (1)

20-20: LGTM! Colorized listening address improves startup visibility.

The use of BRIGHT_MAGENTA() for the listening address makes it stand out in logs, which is helpful for quickly identifying where the service is running. The implementation correctly wraps the address with color codes and resets afterward, and will gracefully degrade to plain text when colors are disabled.

Also applies to: 33-33, 97-97

core/src/test/resources/log4j2.xml (1)

2-2: Test logging configuration enables ANSI colors.

While disableAnsi="false" is consistent with the other logging configurations, note that TerminalColors.detectAnsiSupport() specifically checks for CI environments and returns false. However, Log4j2 will still emit ANSI codes since it's configured to do so at the framework level. This typically works fine in modern CI systems, but if test logs appear garbled in CI output, this would be the configuration to adjust.

Also applies to: 5-7

core/src/main/java/com/predic8/membrane/core/util/OSUtil.java (1)

22-24: LGTM! Windows detection simplified.

The change from checking "windows" to "win" is appropriate and makes the detection more robust across different Windows versions (Windows 10, Windows 11, Windows Server, etc.).

core/src/test/java/com/predic8/membrane/core/http/Http11Test.java (1)

26-26: LGTM! Import path updated for TextUtil package reorganization.

The static import change aligns with the broader refactor moving TextUtil to the util.text subpackage.

core/src/main/java/com/predic8/membrane/core/prettifier/TextPrettifier.java (1)

22-22: LGTM! Import path updated for TextUtil package reorganization.

The static import change aligns with the relocation of TextUtil to the util.text subpackage.

core/src/main/java/com/predic8/membrane/core/interceptor/acl/matchers/GlobMatcher.java (1)

18-18: LGTM! Import path updated for TextUtil package reorganization.

The static import change for globToRegExp aligns with the relocation of TextUtil to the util.text subpackage.

core/src/main/java/com/predic8/membrane/core/exchangestore/FileExchangeStore.java (1)

32-32: LGTM! Import updated to use XMLTextUtil for XML formatting.

The change from TextUtil.* to XMLTextUtil.* appropriately separates XML-specific formatting utilities (like formatXML used on line 184) into a dedicated utility class.

core/src/main/java/com/predic8/membrane/core/interceptor/server/WebServerInterceptor.java (1)

22-22: LGTM! Import path updated for util package reorganization.

The import change aligns with the relocation of text utilities to the util.text subpackage. TextUtil usage on line 316 remains unchanged.

core/src/main/java/com/predic8/membrane/core/lang/spel/spelable/SpELHeader.java (1)

20-20: LGTM! Import path updated for TextUtil package reorganization.

The static import change for camelToKebab aligns with the relocation of TextUtil to the util.text subpackage. Usage on line 35 remains unchanged.

core/src/main/java/com/predic8/membrane/core/graphql/GraphQLProtectionInterceptor.java (1)

23-23: LGTM! Import path updated for util package reorganization.

The import change aligns with the relocation of text utilities to the util.text subpackage. TextUtil usage on line 190 remains unchanged.

core/src/main/java/com/predic8/membrane/core/interceptor/templating/AbstractTemplateInterceptor.java (1)

34-34: Import path update to new StringUtil package looks correct

truncateAfter is now sourced from com.predic8.membrane.core.util.text.StringUtil, which matches the refactored utility location; behavior stays the same.

core/src/main/java/com/predic8/membrane/core/openapi/serviceproxy/APIProxy.java (1)

41-41: maskNonPrintableCharacters import aligned with util.text.StringUtil

The updated static import correctly targets com.predic8.membrane.core.util.text.StringUtil.maskNonPrintableCharacters, keeping assignOpenAPIName behavior unchanged.

core/src/main/java/com/predic8/membrane/core/interceptor/templating/TemplateInterceptor.java (1)

34-34: addLineNumbers now consistently sourced from text.StringUtil

The static import switch to com.predic8.membrane.core.util.text.StringUtil.addLineNumbers matches the refactored utility class and keeps template error diagnostics intact.

core/src/main/java/com/predic8/membrane/core/interceptor/jwt/Jwks.java (1)

25-25: TextUtil import updated to util.text package

getLongDescription() continues to use TextUtil.toEnglishList with the class now correctly imported from com.predic8.membrane.core.util.text.TextUtil.

core/src/main/java/com/predic8/membrane/core/interceptor/administration/AdminRESTInterceptor.java (1)

39-39: Switch to XMLTextUtil.formatXML matches XML beautification usage

Using com.predic8.membrane.core.util.xml.XMLTextUtil.formatXML for getBeautifiedBody aligns with the XML‑focused utility class and matches the (InputStream, boolean) signature.

core/src/test/java/com/predic8/membrane/core/interceptor/schemavalidation/SOAPMessageValidatorInterceptorTest.java (1)

26-26: Tests now use XMLTextUtil.formatXML consistently

The static import and getContent implementation correctly target XMLTextUtil.formatXML(Reader), keeping the test behavior while aligning with the new XML utility class.

Also applies to: 157-159

core/src/main/java/com/predic8/membrane/core/interceptor/schemavalidation/ValidatorInterceptor.java (1)

36-36: linkURL import moved to util.text.TextUtil

getLongDescription() now pulls linkURL from com.predic8.membrane.core.util.text.TextUtil, matching the refactored text utilities without altering output.

core/src/main/java/com/predic8/membrane/core/transport/http/Connection.java (1)

32-32: Connection now imports text utilities from util.text.TextUtil

The wildcard static import has been repointed to com.predic8.membrane.core.util.text.TextUtil.*, keeping isNullOrEmpty and any future text helpers available without changing connection logic.

core/src/main/java/com/predic8/membrane/core/interceptor/log/access/AccessLogInterceptorService.java (1)

30-32: Static import now correctly targets moved TextUtil

Switching the static import to com.predic8.membrane.core.util.text.TextUtil.* keeps escapeQuotes resolution consistent with the TextUtil move. No functional changes in this class.

core/src/test/java/com/predic8/membrane/core/util/StringUtilTest.java (1)

19-20: Test static import aligned with new StringUtil package

Importing from com.predic8.membrane.core.util.text.StringUtil.* matches the class move; the existing tests still exercise the same APIs.

core/src/main/java/com/predic8/membrane/core/interceptor/administration/AdminPageBuilder.java (2)

38-39: XML snippet validation correctly moved to XMLTextUtil

Using XMLTextUtil.isValidXMLSnippet for shortDescription/longDescription keeps the previous behavior of only inlining valid XML and HTML‑escaping everything else, while separating XML logic from generic TextUtil. Looks consistent with the new utility split.

Also applies to: 621-627


637-642: Refactored help/expand icon helpers keep IDs consistent with JS

createHelpIcon(Interceptor) and createExpandIcon(String) integrate cleanly with createShowIconsScript: the i*, e*, and c* IDs still match the jQuery selectors, and null helpId is handled gracefully. No functional regressions apparent.

Also applies to: 703-721

core/src/main/java/com/predic8/membrane/core/transport/http/HttpServerHandler.java (1)

38-40: StringUtil import move preserves masking/truncation behavior

Using com.predic8.membrane.core.util.text.StringUtil.maskNonPrintableCharacters and truncateAfter keeps getLineMaskedAndTruncated identical in behavior after the package move.

Also applies to: 159-161

core/src/main/java/com/predic8/membrane/core/util/text/TextUtil.java (1)

15-16: TextUtil package move cleanly separates text vs. XML concerns

Moving TextUtil to com.predic8.membrane.core.util.text and dropping XML‑specific helpers (now in XMLTextUtil) keeps existing text APIs intact while clarifying responsibilities between text and XML utilities.

core/src/main/java/com/predic8/membrane/core/util/xml/XMLTextUtil.java (1)

72-95: XML snippet validation matches previous behavior and uses hardened XMLInputFactory

isValidXMLSnippet wraps the snippet in a synthetic root element and parses it via XMLInputFactoryFactory.inputFactory(), then checks for an EndDocument event. This preserves the earlier semantics for “balanced, well‑formed snippet” while benefiting from the existing XMLInputFactory hardening (no external entities, DTD disabled, etc.). The resource is closed in a finally block, and failures only result in a false return.

Comment thread distribution/conf/log4j2.xml
Comment thread distribution/router/conf/log4j2.xml Outdated
Comment thread docs/ROADMAP.md
…e consistency

- Changed fallback return value in `TerminalColors` to `false` for safer behavior.
- Updated exception type in `XMLTextUtil` to match method operations.
- Refined imports in `GrammarMock` for conciseness.
- Removed unused exceptions in `HttpServerHandler` to simplify method signatures.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (2)
core/src/main/java/com/predic8/membrane/core/util/text/TerminalColors.java (2)

22-24: Avoid class‑level @SuppressWarnings("unused") where possible

Putting @SuppressWarnings("unused") on the whole class will also hide genuinely unused methods if this utility grows. Consider either:

  • Dropping the suppression entirely and letting the compiler/IDE show unused members, or
  • Narrowing the suppression to specific methods that are intentionally kept for future use.

120-160: Heuristics in detectAnsiSupport() could be slightly tightened and hardened

The overall flow (explicit MEMBRANE_COLORS override → CI guard → IDE/terminal heuristics → OS fallback) is reasonable, but you might want to consider:

  • Wrapping the System.getenv / System.getProperty calls in a small try/catch for SecurityException and falling back to false, to avoid class‑init failures in restricted environments.
  • Reconsidering the very broad TERM_PROGRAM != null check (Lines 142‑143). It currently enables colors for any unknown program that sets this variable; restricting this to known good values or OS combinations would reduce the chance of mis‑detecting dumb terminals.

These are minor robustness tweaks; behavior as written is still acceptable.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 9c69104 and 1b8c173.

📒 Files selected for processing (4)
  • annot/src/test/java/com/predic8/membrane/annot/util/GrammarMock.java (1 hunks)
  • core/src/main/java/com/predic8/membrane/core/transport/http/HttpServerHandler.java (4 hunks)
  • core/src/main/java/com/predic8/membrane/core/util/text/TerminalColors.java (1 hunks)
  • core/src/main/java/com/predic8/membrane/core/util/xml/XMLTextUtil.java (1 hunks)
🧰 Additional context used
🧠 Learnings (3)
📚 Learning: 2025-08-22T15:02:24.810Z
Learnt from: predic8
Repo: membrane/api-gateway PR: 2068
File: core/src/main/java/com/predic8/membrane/core/util/TextUtil.java:119-128
Timestamp: 2025-08-22T15:02:24.810Z
Learning: XMLBeautifier.parse(InputStream) throws Exception, not XMLStreamException specifically, so catching IOException in TextUtil.formatXML is appropriate for handling IO errors during XML parsing.

Applied to files:

  • core/src/main/java/com/predic8/membrane/core/util/xml/XMLTextUtil.java
📚 Learning: 2025-08-22T15:02:24.810Z
Learnt from: predic8
Repo: membrane/api-gateway PR: 2068
File: core/src/main/java/com/predic8/membrane/core/util/TextUtil.java:119-128
Timestamp: 2025-08-22T15:02:24.810Z
Learning: XMLBeautifier.parse(InputStream) throws IOException specifically, not Exception. It internally wraps any XMLStreamException or other parsing exceptions in an IOException. Therefore, catching IOException in TextUtil.formatXML is the correct approach for handling XML parsing errors from InputStream.

Applied to files:

  • core/src/main/java/com/predic8/membrane/core/util/xml/XMLTextUtil.java
📚 Learning: 2025-08-22T15:02:24.810Z
Learnt from: predic8
Repo: membrane/api-gateway PR: 2068
File: core/src/main/java/com/predic8/membrane/core/util/TextUtil.java:119-128
Timestamp: 2025-08-22T15:02:24.810Z
Learning: XMLBeautifier.parse(InputStream) and XMLBeautifier.parse(Reader) both declare "throws Exception" in their signatures, not XMLStreamException specifically. Catching IOException is appropriate for handling IO errors during XML parsing with XMLBeautifier.

Applied to files:

  • core/src/main/java/com/predic8/membrane/core/util/xml/XMLTextUtil.java
🧬 Code graph analysis (4)
annot/src/test/java/com/predic8/membrane/annot/util/GrammarMock.java (1)
annot/src/main/java/com/predic8/membrane/annot/generator/kubernetes/Grammar.java (1)
  • Grammar (30-207)
core/src/main/java/com/predic8/membrane/core/util/xml/XMLTextUtil.java (1)
core/src/main/java/com/predic8/xml/beautifier/XMLInputFactoryFactory.java (1)
  • XMLInputFactoryFactory (24-60)
core/src/main/java/com/predic8/membrane/core/util/text/TerminalColors.java (2)
core/src/main/java/com/predic8/membrane/core/util/text/StringUtil.java (1)
  • StringUtil (19-86)
core/src/main/java/com/predic8/membrane/core/util/OSUtil.java (1)
  • OSUtil (21-52)
core/src/main/java/com/predic8/membrane/core/transport/http/HttpServerHandler.java (1)
core/src/main/java/com/predic8/membrane/core/util/text/StringUtil.java (1)
  • StringUtil (19-86)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: Automated tests
  • GitHub Check: Analyze (java)
🔇 Additional comments (5)
annot/src/test/java/com/predic8/membrane/annot/util/GrammarMock.java (2)

1-14: License header looks correct and consistent

Apache 2.0 header and year update to 2025 look fine and in line with the rest of the project.


19-25: Good switch to Map interface and final field

Using Map<String, Class<?>> with a final reference and HashMap as the implementation is a solid, idiomatic improvement for this test helper; no behavioral change and clearer intent.

core/src/main/java/com/predic8/membrane/core/util/xml/XMLTextUtil.java (1)

1-97: Previous review feedback has been addressed; implementation looks solid.

The Javadoc for the asHTML parameter now correctly describes HTML vs. plain XML formatting, and both formatXML overloads properly catch and log IOException as recommended. The implementation demonstrates good practices:

  • isValidXMLSnippet uses secure XML parsing via XMLInputFactoryFactory (which disables external entities and DTDs)
  • Proper resource cleanup with exception suppression in the finally block
  • Appropriate logging levels (info for I/O errors, debug for validation failures)
  • The snippet validation wraps content in a root element to handle fragments correctly
core/src/main/java/com/predic8/membrane/core/transport/http/HttpServerHandler.java (1)

38-39: LGTM! Clean refactoring of imports and control flow.

The import path updates from com.predic8.membrane.core.util.StringUtil to com.predic8.membrane.core.util.text.StringUtil correctly reflect the package restructuring. The removal of TerminateException from method signatures (lines 177, 208, 267) represents a good refactoring from exception-based control flow to return-based control flow using RequestProcessingResult, which is more appropriate for non-exceptional termination conditions.

Also applies to: 177-177, 208-208, 267-267

core/src/main/java/com/predic8/membrane/core/util/text/TerminalColors.java (1)

46-118: Color API design and enable/disable behavior look solid

The separation between raw codes (*_) and the public methods that honor the enabled flag is clean, and the wrappers (error/warn/info/success, bright*, bold/underline) all correctly degrade to plain strings when colors are disabled. This should make it easy to adopt colors incrementally without risking corrupted log output.

Comment thread core/src/main/java/com/predic8/membrane/core/util/OSUtil.java Outdated
Comment thread docs/ROADMAP.md Outdated
- Corrected OS detection for Windows by using full "windows" string match.
- Added 7.1.0 section to the roadmap, noting JSON Schema registration.
# Conflicts:
#	core/src/main/java/com/predic8/membrane/core/lang/spel/spelable/SpELCookie.java
#	core/src/main/java/com/predic8/membrane/core/lang/spel/spelable/SpELHeader.java
#	core/src/main/java/com/predic8/membrane/core/util/text/StringUtil.java
#	core/src/main/java/com/predic8/membrane/core/util/text/TextUtil.java
#	core/src/test/java/com/predic8/membrane/core/lang/spel/spelable/SPeLablePropertyAwareTest.java
#	core/src/test/java/com/predic8/membrane/core/util/StringUtilTest.java
…`TextUtil` usage, reorganize utility imports, and fix minor inconsistencies

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

♻️ Duplicate comments (2)
docs/ROADMAP.md (2)

17-17: Format bare URL as a markdown link (duplicate of previous review).

The URL violates markdown best practices (MD034). Wrap it in bracket-parenthesis syntax to create a proper link.

-- Register JSON Schema for YAML at: https://www.schemastore.org
+- Register JSON Schema for YAML at: [schemastore.org](https://www.schemastore.org/)

24-24: Fix spelling error: "desciption" → "description" (duplicate of previous review).

Typo in roadmap item description persists from previous review.

-- Central desciption of MEMBRANE_* environment variables
+- Central description of MEMBRANE_* environment variables
🧹 Nitpick comments (2)
core/src/test/java/com/predic8/membrane/core/util/TextUtilTest.java (1)

22-24: Remove redundant specific static imports.

Line 22's wildcard import static com.predic8.membrane.core.util.text.TextUtil.* already imports all static methods from TextUtil, making the specific imports on lines 23-24 redundant.

Apply this diff to remove the redundant imports:

 import static com.predic8.membrane.core.util.text.TextUtil.*;
-import static com.predic8.membrane.core.util.text.TextUtil.getLineFromMultilineString;
-import static com.predic8.membrane.core.util.text.TextUtil.removeFinalChar;
 import static java.nio.charset.StandardCharsets.*;
core/src/main/java/com/predic8/membrane/core/util/text/TerminalColors.java (1)

18-18: Remove unused import.

The regular import of StringUtil on line 18 is not used anywhere in the code. Only the static imports on lines 20-21 are actually used.

Apply this diff:

 package com.predic8.membrane.core.util.text;
 
 import com.predic8.membrane.core.util.*;
-import com.predic8.membrane.core.util.StringUtil;
 
 import static com.predic8.membrane.core.util.StringUtil.no;
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 7a6289f and 792ca26.

📒 Files selected for processing (11)
  • core/src/main/java/com/predic8/membrane/core/graphql/GraphQLProtectionInterceptor.java (3 hunks)
  • core/src/main/java/com/predic8/membrane/core/interceptor/server/WebServerInterceptor.java (3 hunks)
  • core/src/main/java/com/predic8/membrane/core/interceptor/xml/Json2XmlInterceptor.java (1 hunks)
  • core/src/main/java/com/predic8/membrane/core/lang/javascript/RhinoJavascriptLanguageSupport.java (2 hunks)
  • core/src/main/java/com/predic8/membrane/core/openapi/serviceproxy/APIProxy.java (0 hunks)
  • core/src/main/java/com/predic8/membrane/core/transport/http/HttpServerHandler.java (3 hunks)
  • core/src/main/java/com/predic8/membrane/core/util/text/StringUtil.java (1 hunks)
  • core/src/main/java/com/predic8/membrane/core/util/text/TerminalColors.java (1 hunks)
  • core/src/main/java/com/predic8/membrane/core/util/text/TextUtil.java (1 hunks)
  • core/src/test/java/com/predic8/membrane/core/util/TextUtilTest.java (4 hunks)
  • docs/ROADMAP.md (1 hunks)
💤 Files with no reviewable changes (1)
  • core/src/main/java/com/predic8/membrane/core/openapi/serviceproxy/APIProxy.java
🚧 Files skipped from review as they are similar to previous changes (2)
  • core/src/main/java/com/predic8/membrane/core/util/text/StringUtil.java
  • core/src/main/java/com/predic8/membrane/core/interceptor/xml/Json2XmlInterceptor.java
🧰 Additional context used
🧠 Learnings (2)
📚 Learning: 2025-08-22T15:02:24.810Z
Learnt from: predic8
Repo: membrane/api-gateway PR: 2068
File: core/src/main/java/com/predic8/membrane/core/util/TextUtil.java:119-128
Timestamp: 2025-08-22T15:02:24.810Z
Learning: XMLBeautifier.parse(InputStream) throws Exception, not XMLStreamException specifically, so catching IOException in TextUtil.formatXML is appropriate for handling IO errors during XML parsing.

Applied to files:

  • core/src/main/java/com/predic8/membrane/core/util/text/TextUtil.java
📚 Learning: 2025-08-22T15:02:24.810Z
Learnt from: predic8
Repo: membrane/api-gateway PR: 2068
File: core/src/main/java/com/predic8/membrane/core/util/TextUtil.java:119-128
Timestamp: 2025-08-22T15:02:24.810Z
Learning: XMLBeautifier.parse(InputStream) throws IOException specifically, not Exception. It internally wraps any XMLStreamException or other parsing exceptions in an IOException. Therefore, catching IOException in TextUtil.formatXML is the correct approach for handling XML parsing errors from InputStream.

Applied to files:

  • core/src/main/java/com/predic8/membrane/core/util/text/TextUtil.java
🧬 Code graph analysis (5)
core/src/main/java/com/predic8/membrane/core/interceptor/server/WebServerInterceptor.java (1)
core/src/main/java/com/predic8/membrane/core/util/text/TextUtil.java (1)
  • TextUtil (33-332)
core/src/main/java/com/predic8/membrane/core/lang/javascript/RhinoJavascriptLanguageSupport.java (1)
core/src/main/java/com/predic8/membrane/core/util/text/TextUtil.java (1)
  • TextUtil (33-332)
core/src/main/java/com/predic8/membrane/core/graphql/GraphQLProtectionInterceptor.java (1)
core/src/main/java/com/predic8/membrane/core/util/text/TextUtil.java (1)
  • TextUtil (33-332)
core/src/test/java/com/predic8/membrane/core/util/TextUtilTest.java (1)
core/src/main/java/com/predic8/membrane/core/util/text/TextUtil.java (1)
  • TextUtil (33-332)
core/src/main/java/com/predic8/membrane/core/util/text/TerminalColors.java (2)
core/src/main/java/com/predic8/membrane/core/util/text/StringUtil.java (1)
  • StringUtil (21-91)
core/src/main/java/com/predic8/membrane/core/util/OSUtil.java (1)
  • OSUtil (21-52)
🪛 LanguageTool
docs/ROADMAP.md

[grammar] ~24-~24: Ensure spelling is correct
Context: ...ystem.console() is available) - Central desciption of MEMBRANE_* environment variables -...

(QB_NEW_EN_ORTHOGRAPHY_ERROR_IDS_1)

🪛 markdownlint-cli2 (0.18.1)
docs/ROADMAP.md

17-17: Bare URL used

(MD034, no-bare-urls)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: Automated tests
  • GitHub Check: Analyze (java)
🔇 Additional comments (10)
core/src/main/java/com/predic8/membrane/core/interceptor/server/WebServerInterceptor.java (2)

23-23: Static text-util imports are consistent with the new package usage

Using com.predic8.membrane.core.util.text.* plus a static import of TextUtil.* matches the refactor pattern in this PR and does not change behavior.

Also applies to: 40-40


318-318: getShortDescription now uses static import; behavior remains the same

Switching from TextUtil.linkURL(docBase) to linkURL(docBase) via static import is behaviorally identical and continues to HTML-escape / linkify docBase as before.

core/src/main/java/com/predic8/membrane/core/transport/http/HttpServerHandler.java (1)

177-177: The refactoring from exception-based to return-value-based termination signaling is safe and complete.

The removal of TerminateException from the throws clauses of processSingleRequest, processHttp1Request, and process is correct. No code in the codebase catches or expects TerminateException from these methods. The shift to signaling termination via RequestProcessingResult return values is cleaner and more explicit than exception-based control flow.

core/src/main/java/com/predic8/membrane/core/util/text/TextUtil.java (1)

15-15: LGTM! Package relocation.

The package move to com.predic8.membrane.core.util.text appropriately organizes text-related utilities into a dedicated subpackage.

core/src/main/java/com/predic8/membrane/core/lang/javascript/RhinoJavascriptLanguageSupport.java (1)

18-18: LGTM! Import updates align with package refactoring.

The addition of the text package import and static import of TextUtil.* correctly reflects the package relocation, and the simplified method call on line 55 appropriately leverages the static import.

Also applies to: 26-27, 55-55

core/src/main/java/com/predic8/membrane/core/graphql/GraphQLProtectionInterceptor.java (1)

24-24: LGTM! Consistent with package refactoring.

The import updates and simplified method call align with the TextUtil package relocation to com.predic8.membrane.core.util.text.

Also applies to: 33-33, 192-192

core/src/test/java/com/predic8/membrane/core/util/TextUtilTest.java (1)

81-97: LGTM! Test updates consistent with static imports.

The method calls correctly leverage the static imports, and the test method rename maintains test coverage.

Also applies to: 231-237

core/src/main/java/com/predic8/membrane/core/util/text/TerminalColors.java (3)

27-48: LGTM! Well-designed utility class.

The class structure is appropriate:

  • final class with private constructor prevents instantiation and extension
  • volatile flag ensures thread-safe visibility
  • Static initializer with auto-detection provides good defaults
  • Public control methods offer flexibility

50-98: LGTM! Clean ANSI code implementation.

The approach of private constants with public getters that respect the enabled flag is elegant and allows colors to be cleanly disabled without null checks or conditionals at call sites.


124-164: LGTM! Comprehensive environment detection.

The detectAnsiSupport() method provides thorough environment detection with sensible defaults:

  • User override via MEMBRANE_COLORS provides control
  • CI environment detection prevents color output in build logs
  • IDE detection (IntelliJ, VSCode) enables colors appropriately
  • Terminal capability checks (TERM, TERM_PROGRAM)
  • Windows-specific handling for modern terminals

The logic progression from explicit override → environment detection → conservative default is well-structured.

Comment thread core/src/main/java/com/predic8/membrane/core/util/text/TerminalColors.java Outdated
@predic8

predic8 commented Dec 6, 2025

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Dec 6, 2025

Copy link
Copy Markdown
Contributor
✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

♻️ Duplicate comments (1)
core/src/main/java/com/predic8/membrane/core/util/text/TerminalColors.java (1)

19-22: Fix StringUtil static import target and remove commented-out imports.

detectAnsiSupport() uses yes/no, which (per core/src/main/java/com/predic8/membrane/core/util/text/StringUtil.java) live in the com.predic8.membrane.core.util.text package, while the current static import points to com.predic8.membrane.core.util.StringUtil.*. This is likely a compile error unless a second StringUtil exists, and the commented-out imports are stale.

Consider tightening the import and dropping the dead code:

-import static com.predic8.membrane.core.util.StringUtil.*;
-
-//import static com.predic8.membrane.core.util.StringUtil.no;
-//import static com.predic8.membrane.core.util.text.StringUtil.yes;
+import static com.predic8.membrane.core.util.text.StringUtil.no;
+import static com.predic8.membrane.core.util.text.StringUtil.yes;

You can confirm the actual StringUtil location(s) with:

#!/bin/bash
fd StringUtil.java
rg -n "class StringUtil" -S
🧹 Nitpick comments (1)
core/src/test/java/com/predic8/membrane/core/util/TextUtilTest.java (1)

228-234: Consider renaming test method to follow Java naming conventions.

The test method name remove_Final_Char uses snake_case with mixed capitalization, which is inconsistent with Java naming conventions and other test methods in this class (e.g., getLineFromMultilineStringTest, escapeQuoteSimple).

Consider renaming to camelCase:

-    void remove_Final_Char() {
+    void removeFinalChar() {

or

-    void remove_Final_Char() {
+    void testRemoveFinalChar() {
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 792ca26 and 1bf6d8d.

📒 Files selected for processing (2)
  • core/src/main/java/com/predic8/membrane/core/util/text/TerminalColors.java (1 hunks)
  • core/src/test/java/com/predic8/membrane/core/util/TextUtilTest.java (4 hunks)
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-08-24T17:55:06.089Z
Learnt from: rrayst
Repo: membrane/api-gateway PR: 2068
File: core/src/main/java/com/predic8/membrane/core/util/TextUtil.java:178-183
Timestamp: 2025-08-24T17:55:06.089Z
Learning: The capitalizeFirstCharacter method in TextUtil.java incorrectly uppercases the entire string instead of just the first character due to calling .toUpperCase() on the concatenated result. The method should only capitalize the first Unicode code point and leave the rest unchanged.

Applied to files:

  • core/src/test/java/com/predic8/membrane/core/util/TextUtilTest.java
🧬 Code graph analysis (2)
core/src/main/java/com/predic8/membrane/core/util/text/TerminalColors.java (2)
core/src/main/java/com/predic8/membrane/core/util/text/StringUtil.java (1)
  • StringUtil (21-91)
core/src/main/java/com/predic8/membrane/core/util/OSUtil.java (1)
  • OSUtil (21-52)
core/src/test/java/com/predic8/membrane/core/util/TextUtilTest.java (1)
core/src/main/java/com/predic8/membrane/core/util/text/TextUtil.java (1)
  • TextUtil (33-332)
🔇 Additional comments (2)
core/src/test/java/com/predic8/membrane/core/util/TextUtilTest.java (2)

21-21: LGTM: Static import updated correctly.

The static import path has been correctly updated to reflect the relocation of TextUtil to the util.text package.


78-92: LGTM: Method calls simplified correctly.

The method calls now leverage the static import, making the code more concise while maintaining the same functionality.

…ity methods

- Added colorized logging for different log levels using `TerminalColors`.
- Refined `OSUtil` with new constants, IntelliJ/VSCode detection, and JVM argument helper.
- Simplified ANSI support detection logic in `TerminalColors`.
- Removed redundant imports and simplified method calls in `TerminalColors` and `OSUtil`.
- Unified OS detection patterns for macOS, Windows, and Linux/Unix systems.
- Improved readability and consistency in terminal color support logic.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 4

♻️ Duplicate comments (1)
core/src/main/java/com/predic8/membrane/core/util/text/TerminalColors.java (1)

20-21: Remove commented-out imports.

These commented-out import statements should be removed from the codebase.

🧹 Nitpick comments (1)
core/src/main/java/com/predic8/membrane/core/interceptor/log/LogInterceptor.java (1)

141-143: LGTM: Colored log output for better terminal visibility.

The colored output enhances readability in terminal environments. The TerminalColors.detectAnsiSupport() logic appropriately disables colors in CI and non-terminal contexts.

Consider documenting in the class Javadoc that terminal colors are applied when supported, and that they can be controlled via the MEMBRANE_COLORS environment variable if users need to override the auto-detection behavior.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1bf6d8d and 604425a.

📒 Files selected for processing (3)
  • core/src/main/java/com/predic8/membrane/core/interceptor/log/LogInterceptor.java (3 hunks)
  • core/src/main/java/com/predic8/membrane/core/util/OSUtil.java (2 hunks)
  • core/src/main/java/com/predic8/membrane/core/util/text/TerminalColors.java (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
core/src/main/java/com/predic8/membrane/core/util/text/TerminalColors.java (2)
core/src/main/java/com/predic8/membrane/core/util/OSUtil.java (1)
  • OSUtil (23-84)
core/src/main/java/com/predic8/membrane/core/util/text/StringUtil.java (1)
  • StringUtil (21-91)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: Automated tests
  • GitHub Check: Analyze (java)
🔇 Additional comments (5)
core/src/main/java/com/predic8/membrane/core/util/text/TerminalColors.java (3)

26-30: LGTM: Thread-safe initialization.

The use of volatile ensures visibility across threads for the enable/disable toggle, and the static initializer safely detects ANSI support at class load time.


221-253: LGTM: Comprehensive ANSI support detection.

The detection logic correctly prioritizes user override, appropriately disables colors in CI environments, and provides sensible platform-specific checks with a conservative default.


74-219: LGTM: Color getters and wrapper methods.

All color/style getters correctly respect the enabled flag, and wrapper methods properly apply color codes with reset sequences.

core/src/main/java/com/predic8/membrane/core/interceptor/log/LogInterceptor.java (1)

23-23: LGTM: Necessary imports added.

The imports correctly reference the new TerminalColors utility and text utilities package.

Also applies to: 32-32

core/src/main/java/com/predic8/membrane/core/util/OSUtil.java (1)

59-62: LGTM!

The getJvmArgs() implementation is correct. The @NotNull annotation is appropriate since String.join() never returns null.

Comment thread core/src/main/java/com/predic8/membrane/core/util/OSUtil.java Outdated
Comment thread core/src/main/java/com/predic8/membrane/core/util/OSUtil.java Outdated
Comment thread core/src/main/java/com/predic8/membrane/core/util/OSUtil.java Outdated
Comment thread core/src/main/java/com/predic8/membrane/core/util/text/TerminalColors.java Outdated
- Added system property `MEMBRANE_COLORS` to enable/disable terminal color logging explicitly.
- Fixed null-safe access in OS detection methods.
- Corrected method naming inconsistencies in `OSUtil` and `TerminalColors`.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

♻️ Duplicate comments (1)
core/src/main/java/com/predic8/membrane/core/util/text/TerminalColors.java (1)

20-21: Remove commented‑out imports.

These commented static imports are obsolete and add noise, especially with the wildcard static import already in place. Please delete them.

-//import static com.predic8.membrane.core.util.StringUtil.no;
-//import static com.predic8.membrane.core.util.text.StringUtil.yes;
🧹 Nitpick comments (2)
core/src/main/java/com/predic8/membrane/core/util/text/TerminalColors.java (1)

221-253: Environment‑based ANSI detection is reasonable; consider reusing existing constants.

The detection flow (explicit MEMBRANE_COLORS override → CI off → IDE/terminal checks → OS/TERM heuristics) is sensible and conservative. One small improvement: to avoid string duplication, you could reuse the existing TERM_PROGRAM_ENV constant from OSUtil instead of hardcoding "TERM_PROGRAM" here.

For example:

-        if (isMac()) {
-            // macOS terminal / iTerm2 / xterm / gnome-terminal
-            return System.getenv("TERM_PROGRAM") != null;
-        }
+        if (isMac()) {
+            // macOS terminal / iTerm2 / xterm / gnome-terminal
+            return System.getenv(TERM_PROGRAM_ENV) != null;
+        }
@@
-            // Windows Terminal
-            if (System.getenv("WT_SESSION") != null) return true;
-            return System.getenv("TERM_PROGRAM") != null; // classic cmd/powershell
+            // Windows Terminal
+            if (System.getenv("WT_SESSION") != null) return true;
+            return System.getenv(TERM_PROGRAM_ENV) != null; // classic cmd/powershell
core/src/main/java/com/predic8/membrane/core/util/OSUtil.java (1)

25-38: OS detection improvements look good; consider making the Linux check more explicit.

The switch to OS_NAME_PROPERTY with a null-safe default is solid and avoids NPEs. For isLinux(), consider checking for "linux" instead of "inx" to make the intent clearer and avoid surprising matches in any future exotic os.name values.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 604425a and c51d46b.

📒 Files selected for processing (3)
  • core/src/main/java/com/predic8/membrane/core/interceptor/log/LogInterceptor.java (4 hunks)
  • core/src/main/java/com/predic8/membrane/core/util/OSUtil.java (2 hunks)
  • core/src/main/java/com/predic8/membrane/core/util/text/TerminalColors.java (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • core/src/main/java/com/predic8/membrane/core/interceptor/log/LogInterceptor.java
🧰 Additional context used
🧬 Code graph analysis (1)
core/src/main/java/com/predic8/membrane/core/util/text/TerminalColors.java (2)
core/src/main/java/com/predic8/membrane/core/util/OSUtil.java (1)
  • OSUtil (23-83)
core/src/main/java/com/predic8/membrane/core/util/text/StringUtil.java (1)
  • StringUtil (21-91)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: Automated tests
  • GitHub Check: Analyze (java)
🔇 Additional comments (6)
core/src/main/java/com/predic8/membrane/core/util/text/TerminalColors.java (3)

26-45: Enabled flag initialization and toggling look correct.

Using a volatile enabled flag initialized via detectAnsiSupport() and controlled through enable()/disable()/isEnabled() is thread‑safe and straightforward. No issues here.


47-149: Color/style constants and getters behave as expected.

ANSI codes are correct, and returning "" when disabled ensures callers get plain text without needing extra guards. This pattern is consistent across all colors and styles.


150-219: Semantic aliases and wrappers are consistent and degrade gracefully.

ERROR/WARN/INFO/SUCCESS and the bright/bold/underline wrappers correctly compose color + text + reset, and when colors are disabled they reduce to plain text. This is a clean and predictable API.

core/src/main/java/com/predic8/membrane/core/util/OSUtil.java (3)

59-62: Jvm-args helper and @NotNull contract look appropriate.

Centralizing the JVM argument retrieval in getJvmArgs() with an explicit @NotNull return type is clear and straightforward; no issues from my side.


64-78: IntelliJ environment detection is coherent and no longer conflates VSCode.

Combining JVM-argument checks with IntelliJ-specific system properties and terminal env vars gives a reasonable signal for “runs in IntelliJ”, and keeping VSCode out of this method aligns with the naming.


80-82: VSCode terminal detection is simple and null-safe.

Using "vscode".equalsIgnoreCase(System.getenv(TERM_PROGRAM_ENV)) correctly handles missing env vars without throwing, and matches the intended TERM_PROGRAM contract; this looks fine as-is.

… detection

- Added new constants for terminal environment variables in `OSUtil`.
- Introduced `isDumbTerminal` method for enhanced Linux/Unix support.
- Refactored `detectAnsiSupport` in `TerminalColors` for better readability and logic reuse.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

♻️ Duplicate comments (2)
core/src/main/java/com/predic8/membrane/core/util/text/TerminalColors.java (2)

21-22: Remove commented-out imports.

These commented lines serve no purpose and should be removed to keep the codebase clean.


235-235: Fix the typo in the method name.

The method runsInVSCodeTerminal() has a typo with a capital 'E' in the middle of "Terminal". This should be corrected in both the method definition in OSUtil.java and this call site.

🧹 Nitpick comments (1)
core/src/main/java/com/predic8/membrane/core/util/text/TerminalColors.java (1)

222-253: Reconsider the isDumbTerminal() logic—the method name is inverted from its behavior.

The isDumbTerminal() method (OSUtil.java, lines 88-94) returns true when the TERM environment variable is set AND not equal to "dumb", meaning it returns true for capable terminals, not dumb ones. This contradicts the method name. At line 249, the code correctly enables ANSI support by checking this method, so the logic itself is not inverted. However, the method name is highly misleading and should be renamed to something like isSmartTerminal() or supportsAnsi() to match its actual behavior.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c51d46b and a096c33.

📒 Files selected for processing (3)
  • core/src/main/java/com/predic8/membrane/core/Constants.java (1 hunks)
  • core/src/main/java/com/predic8/membrane/core/util/OSUtil.java (2 hunks)
  • core/src/main/java/com/predic8/membrane/core/util/text/TerminalColors.java (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: Automated tests
  • GitHub Check: Analyze (java)
🔇 Additional comments (11)
core/src/main/java/com/predic8/membrane/core/util/OSUtil.java (5)

24-31: LGTM! Good use of constants for magic strings.

Extracting environment variable names and property names into public constants improves maintainability and enables reuse across the codebase.


32-42: LGTM! Null-safe OS detection.

The addition of default empty strings to System.getProperty() calls properly addresses the null-safety concern. Using "windows" instead of "win" correctly avoids false positives with "Darwin".


63-66: LGTM!

The method correctly joins JVM arguments and the @NotNull annotation is appropriate since String.join() will return an empty string for an empty list.


68-82: LGTM! Clean separation of IntelliJ detection logic.

The VSCode check has been correctly removed, and the method now accurately detects only IntelliJ environments. The comments clearly separate Run/Debug/Test detection from Terminal detection.


84-86: LGTM! Method is null-safe.

The typo has been fixed. Note that this implementation is actually null-safe because "vscode".equalsIgnoreCase(null) returns false rather than throwing NPE—the equalsIgnoreCase method handles null arguments gracefully when called on a non-null String.

core/src/main/java/com/predic8/membrane/core/Constants.java (1)

27-27: LGTM!

The new constant follows the existing naming convention and provides a centralized reference for the environment variable used to control terminal color output.

core/src/main/java/com/predic8/membrane/core/util/text/TerminalColors.java (5)

24-46: LGTM!

The class structure follows best practices:

  • final class prevents extension
  • Private constructor prevents instantiation
  • volatile ensures thread-safe reads/writes of the enabled flag
  • Static initialization is safe during class loading

49-72: LGTM!

The ANSI escape codes are correct and follow the standard format. The naming convention with trailing underscores clearly distinguishes the private constants from the public getter methods.


75-149: LGTM!

The getter methods follow a consistent pattern, checking the enabled flag and returning either the ANSI code or an empty string. This design allows colors to be toggled without changing call sites.


152-166: LGTM!

Semantic aliases improve code readability and make it easier to maintain a consistent color scheme across the application.


169-220: LGTM!

The wrapper methods provide a convenient API for colorizing text without requiring manual reset codes. The implementation is consistent and correct.

Comment thread core/src/main/java/com/predic8/membrane/core/util/OSUtil.java Outdated
… consistency

- Updated `MEMBRANE_COLORS` to `MEMBRANE_TERM_COLORS` and added new system property `membrane.term.colors`.
- Adjusted references in `LogInterceptor`, `TerminalColors`, and `Constants`.
- Improved logic in `TerminalColors` for explicit fallback handling.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (2)
core/src/main/java/com/predic8/membrane/core/util/text/TerminalColors.java (2)

21-21: Consider removing @SuppressWarnings("unused") and tightening detectAnsiSupport() visibility

With TerminalColors now used from other classes (e.g., Router, HttpEndpointListener, LogInterceptor), the class-level @SuppressWarnings("unused") is likely no longer necessary and may hide genuinely unused helpers over time. Dropping it would let the compiler/IDE surface real dead code if it appears.

Also, unless you intend detectAnsiSupport() to be part of the public API, you could narrow its visibility (e.g., private static or package‑private) since it’s already invoked from the static initializer and not obviously needed by callers. That keeps the public surface focused on enable/disable/isEnabled and the color/style accessors.

Also applies to: 219-219


219-254: Clarify the isDumbTerminal()‑based Linux detection to avoid confusion

On the “Linux” path you enable colors via:

if (isDumbTerminal()) return true;

But per OSUtil.isDumbTerminal() (in core/src/main/java/com/predic8/membrane/core/util/OSUtil.java), the method actually returns true when TERM is not "dumb" and is set, which is correct for enabling ANSI but opposite to what the name suggests.

The behavior is fine, but the naming/usage can be surprising. Consider either:

  • Renaming OSUtil.isDumbTerminal() to something like hasColorCapableTerm() (and inverting its logic), or
  • Adding a short comment here that explicitly notes that isDumbTerminal() returns true for non‑"dumb" terminals, so future readers don’t misinterpret this condition.

This is mainly a readability/maintenance improvement; functionally the detection logic is sound.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a096c33 and 474f79e.

📒 Files selected for processing (3)
  • core/src/main/java/com/predic8/membrane/core/Constants.java (2 hunks)
  • core/src/main/java/com/predic8/membrane/core/interceptor/log/LogInterceptor.java (4 hunks)
  • core/src/main/java/com/predic8/membrane/core/util/text/TerminalColors.java (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • core/src/main/java/com/predic8/membrane/core/interceptor/log/LogInterceptor.java
  • core/src/main/java/com/predic8/membrane/core/Constants.java
🧰 Additional context used
🧬 Code graph analysis (1)
core/src/main/java/com/predic8/membrane/core/util/text/TerminalColors.java (3)
core/src/main/java/com/predic8/membrane/core/Constants.java (1)
  • Constants (24-99)
core/src/main/java/com/predic8/membrane/core/util/OSUtil.java (1)
  • OSUtil (23-95)
core/src/main/java/com/predic8/membrane/core/util/text/StringUtil.java (1)
  • StringUtil (21-91)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Automated tests
🔇 Additional comments (1)
core/src/main/java/com/predic8/membrane/core/util/text/TerminalColors.java (1)

45-217: Color constants and wrappers are well-structured and toggle-aware

The separation between raw ANSI codes, toggle-aware getters, and semantic/wrapper methods (including bright/bold/underline helpers) is clean. Returning empty strings when enabled is false keeps call sites simple and prevents stray reset codes from leaking into logs/console output. This looks good.

…ble and property

- Introduced `MEMBRANE_DISABLE_TERM_COLORS` environment variable and `membrane.disable.term.colors` system property.
- Updated `TerminalColors`, `Constants`, and log4j2 configuration files to support new variables.
- Adjusted ANSI support detection logic to accommodate the disable feature.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
distribution/router/conf/log4j2.xml (1)

10-12: Consider Log4j2 and application ANSI detection alignment.

The Log4j2 configuration uses a simple environment variable toggle (${env:MEMBRANE_DISABLE_TERM_COLORS:-false}), while TerminalColors.detectAnsiSupport() implements sophisticated detection including CI environments, IDE detection, OS checks, and terminal type detection. This means:

  • Log4j2-generated logs will use ANSI colors by default unless the environment variable is explicitly set
  • Application code using TerminalColors may disable colors automatically based on context (CI, dumb terminal, etc.)
  • This could lead to inconsistent behavior where Log4j2 outputs colors but application logs don't (or vice versa)

Consider:

  1. Setting MEMBRANE_DISABLE_TERM_COLORS programmatically in the application startup based on TerminalColors.detectAnsiSupport() before Log4j2 initialization
  2. Or document that users in non-color-supporting environments should set the environment variable manually
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 474f79e and dc77934.

📒 Files selected for processing (6)
  • core/src/main/java/com/predic8/membrane/core/Constants.java (2 hunks)
  • core/src/main/java/com/predic8/membrane/core/Router.java (4 hunks)
  • core/src/main/java/com/predic8/membrane/core/util/text/TerminalColors.java (1 hunks)
  • core/src/test/resources/log4j2.xml (1 hunks)
  • distribution/conf/log4j2.xml (1 hunks)
  • distribution/router/conf/log4j2.xml (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • distribution/conf/log4j2.xml
🧰 Additional context used
🧬 Code graph analysis (2)
core/src/main/java/com/predic8/membrane/core/Router.java (1)
core/src/main/java/com/predic8/membrane/core/Constants.java (1)
  • Constants (24-99)
core/src/main/java/com/predic8/membrane/core/util/text/TerminalColors.java (3)
core/src/main/java/com/predic8/membrane/core/Constants.java (1)
  • Constants (24-99)
core/src/main/java/com/predic8/membrane/core/util/OSUtil.java (1)
  • OSUtil (23-95)
core/src/main/java/com/predic8/membrane/core/util/text/StringUtil.java (1)
  • StringUtil (21-91)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: Automated tests
  • GitHub Check: Analyze (java)
🔇 Additional comments (12)
core/src/main/java/com/predic8/membrane/core/Router.java (3)

55-55: LGTM! Import organization is appropriate.

The wildcard imports for utility packages and static imports for color constants are reasonable and improve code readability.

Also applies to: 71-71, 74-75


360-365: LGTM! Startup logging with terminal colors is well-structured.

The new logStartupMessage() helper appropriately centralizes the startup log and correctly applies colors that gracefully degrade when disabled. The conditional invocation logic properly handles both synchronous and asynchronous initialization paths.

Also applies to: 680-680


686-688: LGTM! Pattern matching improves readability.

The use of pattern matching for instanceof eliminates the need for an explicit cast and makes the code more concise.

distribution/router/conf/log4j2.xml (1)

5-9: LGTM! Clear documentation for disabling colors.

The documentation comment provides clear instructions and a concrete example for users who need to disable terminal colors.

core/src/test/resources/log4j2.xml (2)

2-2: LGTM! Test logging configuration updated consistently.

The test configuration appropriately mirrors the production logging setup with colored output support and the same environment-variable-based toggle. The addition of status="WARN" helps reduce Log4j2 internal logging noise during tests.

Also applies to: 10-12


15-22: LGTM! Logger configuration is appropriate for tests.

The logger hierarchy is properly configured with the core package logger and root logger both directing output to STDOUT, which is appropriate for test environments.

core/src/main/java/com/predic8/membrane/core/Constants.java (2)

27-30: LGTM! Constants are well-organized.

The new constants for terminal color control are appropriately named and organized with a helpful comment distinguishing environment variables from system properties.


49-49: LGTM! Idiomatic catch parameter naming.

Renaming the catch parameter to ignored clearly signals the exception is intentionally not handled, which is appropriate for this fallback scenario.

core/src/main/java/com/predic8/membrane/core/util/text/TerminalColors.java (4)

22-43: LGTM! Utility class structure is well-designed.

The class correctly uses:

  • final to prevent subclassing
  • volatile for thread-safe flag access
  • Private constructor to prevent instantiation
  • Static initialization for one-time ANSI support detection

45-146: LGTM! ANSI code constants and getters are correctly implemented.

The private constants store standard ANSI escape sequences, and the public getter methods appropriately return empty strings when colors are disabled, providing graceful degradation. The naming convention (underscore suffix for private constants) is clear and consistent.


148-217: LGTM! Semantic aliases and wrapper methods enhance usability.

The semantic aliases (ERROR, WARN, INFO, SUCCESS) and convenience wrapper methods follow a consistent pattern and correctly apply RESET() to prevent color bleeding. These provide a user-friendly API for common use cases.


222-228: User override logic is correct but double-check the comments.

The logic correctly handles the "DISABLE" semantics where yes(override) means "disable colors" (return false). The inline comments stating "Logic is reverse here!" are helpful reminders about this inverted logic. The pattern is consistent for both environment variable and system property checks.

Comment thread core/src/main/java/com/predic8/membrane/core/util/text/TerminalColors.java Outdated
…lColors`

- Simplified terminal color detection by inlining `isDumbTerminal` logic directly into `TerminalColors`.
- Removed unused method from `OSUtil`.
- Implemented detailed environment-based terminal color detection in shell and batch scripts.
- Deprecated redundant methods in `OSUtil` while streamlining color detection logic in `TerminalColors`.
- Updated log configuration files to support standardized `membrane.disable.term.colors` system property.
- Improved user control over terminal colors with clear case-insensitive environment overrides.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between dc77934 and b9aa428.

📒 Files selected for processing (8)
  • core/src/main/java/com/predic8/membrane/core/Constants.java (2 hunks)
  • core/src/main/java/com/predic8/membrane/core/util/OSUtil.java (1 hunks)
  • core/src/main/java/com/predic8/membrane/core/util/text/TerminalColors.java (1 hunks)
  • core/src/test/resources/log4j2.xml (1 hunks)
  • distribution/conf/log4j2.xml (1 hunks)
  • distribution/router/conf/log4j2.xml (1 hunks)
  • distribution/scripts/start_router.cmd (1 hunks)
  • distribution/scripts/start_router.sh (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • core/src/main/java/com/predic8/membrane/core/util/OSUtil.java
  • distribution/conf/log4j2.xml
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-07-02T18:05:47.059Z
Learnt from: rrayst
Repo: membrane/api-gateway PR: 1947
File: distribution/tutorials/soap/membrane.sh:17-22
Timestamp: 2025-07-02T18:05:47.059Z
Learning: When using environment variable shortcuts like `$MEMBRANE_HOME` in shell scripts that look for installation directories, validate that required files (like `starter.jar` for Membrane) exist in the candidate directory before returning it. This prevents hard-to-diagnose runtime errors when the environment variable points to an invalid or stale location.

Applied to files:

  • core/src/main/java/com/predic8/membrane/core/Constants.java
🧬 Code graph analysis (1)
core/src/main/java/com/predic8/membrane/core/util/text/TerminalColors.java (1)
core/src/main/java/com/predic8/membrane/core/Constants.java (1)
  • Constants (24-103)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: Automated tests
  • GitHub Check: Analyze (java)
🔇 Additional comments (5)
core/src/test/resources/log4j2.xml (1)

2-13: Test logging color configuration looks coherent and matches runtime wiring

status="WARN" plus the UTF‑8 PatternLayout using disableAnsi="${sys:membrane.disable.term.colors:-false}" and %highlight is consistent with the new MEMBRANE_DISABLE_TERM_COLORS wiring in the rest of the codebase; no functional issues from this change.

core/src/main/java/com/predic8/membrane/core/Constants.java (1)

28-37: Centralizing the color-disabling property in Constants looks good

The MEMBRANE_DISABLE_TERM_COLORS_PROPERTY constant and its JavaDoc nicely document the contract with the start scripts and log configuration, and the small catch-variable rename to ignored is a clean readability improvement.

Also applies to: 53-53

distribution/router/conf/log4j2.xml (1)

5-13: Runtime logging color toggle is wired correctly to the new system property

The console PatternLayout’s disableAnsi="${sys:membrane.disable.term.colors:-false}" and the MEMBRANE_DISABLE_TERM_COLORS documentation align with the new property in Constants and the Unix start script; once the Windows script also forwards -Dmembrane.disable.term.colors, this config will behave consistently across platforms.

distribution/scripts/start_router.sh (1)

32-87: Shell color detection and JVM property wiring look solid

detect_colors covers the documented MEMBRANE_DISABLE_TERM_COLORS override and sensible auto‑detection, and the resulting DISABLE_COLORS is correctly forwarded via -Dmembrane.disable.term.colors=$DISABLE_COLORS so TerminalColors and log4j2 can honor it; no issues from this change.

core/src/main/java/com/predic8/membrane/core/util/text/TerminalColors.java (1)

1-223: Property‑driven TerminalColors implementation is consistent and well‑scoped

The static, volatile-guarded enabled flag, ANSI code constants, semantic helpers, and detectAnsiSupport() logic (inverting the membrane.disable.term.colors system property and defaulting to disabled when unset) all fit together cleanly and align with the updated start scripts and log4j2 configuration; I don’t see further changes needed here.

Comment thread distribution/scripts/start_router.cmd
- Extended `start_router.cmd` to include `JAVA_OPTS` for disabling terminal colors.
- Added support for WezTerm, Alacritty, and Kitty in `start_router.sh`.
- Minor formatting adjustment in `TerminalColors`.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (2)
core/src/main/java/com/predic8/membrane/core/util/text/TerminalColors.java (2)

19-19: Narrow or remove the @SuppressWarnings("unused") annotation.

Suppressing "unused" warnings at the class level is too broad and can hide legitimate issues. If specific methods are genuinely unused but intentionally provided as part of the public API, mark those methods individually. Otherwise, remove unused methods or the annotation entirely.


20-25: Consider adding JavaDoc to document the class contract.

While the implementation is clear, adding JavaDoc would help users understand the enable/disable mechanism, the role of the system property, and the delegation to start scripts for terminal detection. This improves maintainability and reduces cognitive load for future developers.

Example JavaDoc:

/**
 * Provides ANSI terminal color codes with runtime enable/disable support.
 * <p>
 * Color output is controlled by the {@code membrane.disable.term.colors} system property,
 * typically set by the start script based on terminal capability detection.
 * When the property is not set, colors are disabled by default.
 * <p>
 * All color code getters return empty strings when colors are disabled, allowing
 * safe concatenation without conditional logic.
 */
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4e404ab and f248bcf.

📒 Files selected for processing (2)
  • core/src/main/java/com/predic8/membrane/core/util/text/TerminalColors.java (1 hunks)
  • distribution/scripts/start_router.sh (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • distribution/scripts/start_router.sh
🧰 Additional context used
🧬 Code graph analysis (1)
core/src/main/java/com/predic8/membrane/core/util/text/TerminalColors.java (1)
core/src/main/java/com/predic8/membrane/core/Constants.java (1)
  • Constants (24-103)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: Automated tests
  • GitHub Check: Analyze (java)
🔇 Additional comments (4)
core/src/main/java/com/predic8/membrane/core/util/text/TerminalColors.java (4)

22-22: Thread-safety approach is sound.

The volatile modifier ensures visibility of the enabled field across threads, which is appropriate for this toggle pattern. The simple read/write operations don't require stronger synchronization.

Also applies to: 27-37


39-140: Clean API design with appropriate encapsulation.

The pattern of private ANSI code constants with public getters that return empty strings when disabled is well-designed. This allows callers to concatenate color codes without null checks or conditional logic, and the enable/disable toggle is cleanly enforced at the access layer.


142-211: Semantic aliases and convenience wrappers improve usability.

The semantic color names (ERROR, WARN, INFO, SUCCESS) and wrapping methods that automatically apply RESET() make the API more intuitive and reduce boilerplate for callers. The implementation correctly handles the enabled/disabled state through the underlying getter methods.


213-222: Detection logic is appropriate for script-driven configuration.

The implementation correctly delegates terminal capability detection to the start script (as documented in Constants.java), reading only the system property. The conservative default of disabling colors when the property is absent is sensible—it indicates the start script hasn't run or hasn't set the property. The inversion on line 218 correctly handles the "disable" semantics of the property name.

- Added support for WezTerm, Alacritty, and Kitty in `start_router.sh`.
- Minor formatting adjustment in `TerminalColors`.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (2)
core/src/main/java/com/predic8/membrane/core/util/text/TerminalColors.java (2)

29-29: Consider narrowing the scope of @SuppressWarnings.

The class-level @SuppressWarnings("unused") suppresses warnings for all methods, which may hide legitimate unused code. Consider removing it once all public methods are in use, or applying it only to specific methods that are intentionally part of the public API but not yet utilized.


169-221: Document or warn about nesting behavior of wrapper methods.

Each wrapper method automatically appends RESET(), which will cancel any outer styling if these methods are nested. For example, bold(error("text")) produces BOLD + ERROR + "text" + RESET + RESET, where the inner RESET() cancels the bold styling, leaving only plain "text" visible.

Consider adding a JavaDoc note on these methods warning that they should not be nested, or provide alternative methods that don't auto-reset for composition scenarios.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f248bcf and 103248b.

📒 Files selected for processing (1)
  • core/src/main/java/com/predic8/membrane/core/util/text/TerminalColors.java (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
core/src/main/java/com/predic8/membrane/core/util/text/TerminalColors.java (1)
core/src/main/java/com/predic8/membrane/core/Constants.java (1)
  • Constants (24-103)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: Automated tests
  • GitHub Check: Analyze (java)
🔇 Additional comments (1)
core/src/main/java/com/predic8/membrane/core/util/text/TerminalColors.java (1)

223-232: LGTM! Conservative and well-documented detection logic.

The detection method correctly reads the system property, inverts the "disable" semantics, and defaults to disabled when the property is not set. This conservative default prevents unexpected ANSI codes in environments where terminal support is uncertain.

@rrayst rrayst merged commit 63cfcc2 into master Dec 8, 2025
5 checks passed
@rrayst rrayst deleted the tutorial-fail-on-error branch December 8, 2025 08:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants